package com.smartsleep;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.smartsleep.AssessFragment.Mgetdata;
import com.widget.ChartBar;
import com.widget.ConnectDirect;
import com.widget.GetTime;
import com.widget.Url;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

public class QualityActivity extends Activity{
	private int userID = 0;
	private String date = "";
	private View title;
	private View qtitle;
	private ProgressBar myProgressBar;
	private TextView scoretx, durationtx, fallasleep, bedawaytx, movetx,lighttx, sleeptx;
	private int flag = 0;
	private int efficiency;
	private String bedaway, move, asleeptime = "", sleeptime = "",
			waketime = "", bedtime = "";
	private float duration, fallasleepTime;
	@Override
	protected void onCreate(Bundle savedInstanceState){
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.fragment_assess);
		title= (View) findViewById(R.id.title_frame);
		title.setVisibility(View.VISIBLE);
		qtitle= (View) findViewById(R.id.time_title);
		qtitle.setVisibility(View.VISIBLE);	
		Intent intent = getIntent();
		
		duration = intent.getExtras().getFloat("duration");
		durationtx = (TextView) findViewById(R.id.durationtx);
		durationtx.setText(GetTime.convertsleep(duration));
		
		efficiency =intent.getExtras().getInt("efficiency");
		myProgressBar = (ProgressBar) findViewById(R.id.progressbar);
		myProgressBar.setProgress(efficiency);
		scoretx = (TextView) findViewById(R.id.scoretx);
		scoretx.setText(efficiency + "%");
		
		fallasleepTime= intent.getExtras().getFloat("fallasleepTime");
		fallasleep = (TextView) findViewById(R.id.fallasleep);
		fallasleep.setText(GetTime.convertsleep(fallasleepTime));
		
		String hisdate=intent.getStringExtra("date");
		TextView titletx=(TextView) qtitle.findViewById(R.id.timetitle);
		titletx.setText(hisdate);
		
		bedaway=intent.getStringExtra("bedaway");
		bedawaytx = (TextView) findViewById(R.id.bedawaytx);
		bedawaytx.setText(bedaway);
		move=intent.getStringExtra("move");
		movetx = (TextView) findViewById(R.id.movetx);
		movetx.setText(move);		
		
		lighttx = (TextView) findViewById(R.id.lighttx);
		sleeptx = (TextView) findViewById(R.id.deeptx);
		sleeptime=intent.getStringExtra("sleeptime");
		bedtime=intent.getStringExtra("bedtime");
		asleeptime=intent.getStringExtra("asleeptime");
		waketime=intent.getStringExtra("waketime");	
		lighttx.setText(sleeptime + "-" + bedtime);
		sleeptx.setText(asleeptime + "-" + waketime);
		
		LinearLayout arealay = (LinearLayout) findViewById(R.id.assess_area);
		ChartBar area = new ChartBar(this);
		arealay.addView(area);
		//getData();
	}
	
	public void back(View v) {
		finish();
	}
}
